import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../base/Constant.dart';
import '../base/Constant.dart';
import 'GoodsList.dart';

class SearchGoodsPage extends StatefulWidget {
  SearchGoodsPage({Key key}) : super(key: key);

  @override
  _SearchGoodsPageState createState() => _SearchGoodsPageState();
}

class _SearchGoodsPageState extends State<SearchGoodsPage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: PreferredSize(
        child: AppBar(
          brightness: Brightness.light,
          backgroundColor: white,
          elevation: 0,
        ),
        preferredSize: Size.fromHeight(0),
      ),
      backgroundColor: white,
      body: AnnotatedRegion<SystemUiOverlayStyle>(
        child: Column(
          children: <Widget>[
            Container(
              padding: EdgeInsets.fromLTRB(
                  0,
                  ScreenUtil.getInstance().setWidth(DP_20),
                  ScreenUtil.getInstance().setWidth(DP_20),
                  ScreenUtil.getInstance().setWidth(DP_20)),
              color: white,
              child: Center(
                child: new Row(
                  children: <Widget>[
                   GestureDetector(
                     child:  Container(
                      width: ScreenUtil.getInstance().setWidth(DP_80),
                      child: Icon(Icons.arrow_back_ios, color: black_99),
                    ),
                    onTap: (){
                      Navigator.of(context).pop();
                    },
                   ),
                    Expanded(
                      flex: 1,
                      child: Container(
                        margin: EdgeInsets.fromLTRB(
                            ScreenUtil.getInstance().setHeight(DP_10),
                            0,
                            ScreenUtil.getInstance().setHeight(DP_10),
                            0),
                        height: ScreenUtil.getInstance().setHeight(DP_60),
                        decoration: BoxDecoration(
                            color: Color.fromARGB(255, 245, 245, 245),
                            borderRadius: BorderRadius.circular(20.0)),
                        child: ConstrainedBox(
                          constraints: BoxConstraints(maxHeight: DP_80),
                          child: TextField(
                            keyboardAppearance: Brightness.light,
                            maxLines: 1,
                            cursorColor: mainColor,
                            decoration: new InputDecoration(
                                // contentPadding: EdgeInsets.all(0),
                                prefixIcon: Icon(
                                  Icons.search,
                                  color: Colors.black45,
                                ),
                                hintText: "搜索商品、品牌",
                                suffixIcon: ClipOval(
                                  child: Container(
                                    child: Icon(
                                      Icons.clear,
                                      color: Colors.white,
                                      size: ScreenUtil.getInstance()
                                          .setHeight(DP_30),
                                    ),
                                    margin: EdgeInsets.fromLTRB(
                                        80,
                                        ScreenUtil.getInstance()
                                            .setHeight(DP_15),
                                        ScreenUtil.getInstance()
                                            .setHeight(DP_15),
                                        ScreenUtil.getInstance()
                                            .setHeight(DP_15)),
                                    decoration: BoxDecoration(
                                        color: Colors.black45,
                                        borderRadius: BorderRadius.circular(
                                            ScreenUtil.getInstance()
                                                .setHeight(DP_90))),
                                  ),
                                ),
                                border: InputBorder.none,
                                hintStyle: TextStyle(
                                    color: Colors.black45,
                                    fontSize: ScreenUtil.getInstance()
                                        .setSp(NORMAL_FONT_SIZE))),
                          ),
                        ),
                      ),
                    ),
                    GestureDetector(
                      child: Container(
                        alignment: Alignment.center,
                        width: ScreenUtil.getInstance().setWidth(DP_80),
                        child: Text('搜索',
                            style: TextStyle(
                                color: black_99,
                                fontSize: ScreenUtil.getInstance()
                                    .setSp(NORMAL_FONT_SIZE)))),
                                    onTap: (){
                                      Navigator.of(context).push(new MaterialPageRoute(builder:(context){
                                        return new GoodsListPage(cat_id: "5",);
                                      }));
                                    },
                    )
                  ],
                ),
              ),
            ),
            Padding(
                padding:
                    EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_20)),
                child: Row(
                  children: <Widget>[
                    Expanded(
                      child: Text('热门搜索',
                          style: TextStyle(
                              color: black,
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE))),
                    )
                  ],
                )),
            Padding(
              padding: EdgeInsets.fromLTRB(
                  ScreenUtil.getInstance().setHeight(DP_20),
                  0,
                  ScreenUtil.getInstance().setHeight(DP_20),
                  0),
              child: GridView.builder(
                shrinkWrap: true,
                padding: EdgeInsets.only(top: 0),
                physics: new NeverScrollableScrollPhysics(),
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 3,
                    mainAxisSpacing: ScreenUtil.getInstance().setHeight(DP_20),
                    crossAxisSpacing: ScreenUtil.getInstance().setHeight(DP_20),
                    childAspectRatio: 3.5),
                itemBuilder: (BuildContext context, int index) {
                  return GestureDetector(
                    child: Container(
                      decoration: BoxDecoration(
                          color: f0Color,
                          borderRadius: BorderRadius.circular(3)),
                    ),
                  );
                },
                itemCount: 5,
              ),
            ),
            Padding(
                padding:
                    EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_20)),
                child: Row(
                  children: <Widget>[
                    Expanded(
                      child: Text('搜索历史',
                          style: TextStyle(
                              color: black,
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE))),
                    ),
                    Icon(Icons.delete_forever,
                        color: Colors.black45,
                        size: ScreenUtil.getInstance().setHeight(DP_40))
                  ],
                )),
            Padding(
              padding: EdgeInsets.fromLTRB(
                  ScreenUtil.getInstance().setHeight(DP_20),
                  0,
                  ScreenUtil.getInstance().setHeight(DP_20),
                  0),
              child: GridView.builder(
                shrinkWrap: true,
                padding: EdgeInsets.only(top: 0),
                physics: new NeverScrollableScrollPhysics(),
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 3,
                    mainAxisSpacing: ScreenUtil.getInstance().setHeight(DP_20),
                    crossAxisSpacing: ScreenUtil.getInstance().setHeight(DP_20),
                    childAspectRatio: 3.5),
                itemBuilder: (BuildContext context, int index) {
                  return GestureDetector(
                    child: Container(
                      decoration: BoxDecoration(
                          color: f0Color,
                          borderRadius: BorderRadius.circular(3)),
                    ),
                  );
                },
                itemCount: 10,
              ),
            ),
          ],
        ),
        value: SystemUiOverlayStyle.dark,
      ),
    );
  }
}
